cmake_minimum_required (VERSION 2.6)
project (sipclient)

#not build ZERO_CHECK
#set(CMAKE_SUPPRESS_REGENERATION ON)

if (EXISTS "${PROJECT_SOURCE_DIR}/VER")
    file(READ "${PROJECT_SOURCE_DIR}/VER" PKG_VERSION)
else()
    message("VER not found.")
endif ()

message(STATUS "VERSION:${PKG_VERSION}")

# The version number.
set (APP_VERSION_MAJOR 0)
set (APP_VERSION_MINOR 1)
set (APP_VERSION_PATCH 0)
set (APP_VERSION_DATE 20200208)
set (APP_RELEASE_VERSION \"${APP_VERSION_MAJOR}.${APP_VERSION_MINOR}.${APP_VERSION_PATCH}\")
set (APP_INTERNAL_VERSION \"${APP_VERSION_MAJOR}.${APP_VERSION_MINOR}.${APP_VERSION_PATCH}.${APP_VERSION_DATE}\")

set(USE_OPENSSL OFF CACHE BOOL "Flag indicating if compile with openssl or not")
#set(USE_CARES OFF CACHE BOOL "Link against libc-ares (rather than rutil/ares) install libcares and/or set LDFLAGS, or use contrib/ares")

# configure a header file to pass some of the CMake settings
# to the source code
configure_file (
  "${PROJECT_SOURCE_DIR}/config.h.in"
  "${PROJECT_BINARY_DIR}/config.h"
)

set(EXECUTABLE_OUTPUT_PATH ${PROJECT_SOURCE_DIR}/bin)

#set(RUTIL_INCLUDE_DIR "${PROJECT_SOURCE_DIR}/rutil")


set(OS "unknown" CACHE STRING "OS option, Choose 'win' or 'ubuntu16.04' or 'centos6.8' or 'arm-linux' with '-DOS='" )
if(OS STREQUAL "unknown")
  if(WIN32)
    set(OS "win")
    set(LIBRARY_OUTPUT_PATH ${PROJECT_SOURCE_DIR}/lib/Win32)
  elseif(UNIX)
    set(OS "ubuntu16.04")
    set(LIBRARY_OUTPUT_PATH ${PROJECT_SOURCE_DIR}/lib/ubuntu16.04)
  endif()
endif()

message(STATUS "Current OS platform: ${OS}, You can specified one of 'win' or 'ubuntu16.04' or 'centos6.8' or 'arm-linux' with '-DOS='")

include(CheckCXXCompilerFlag)
CHECK_CXX_COMPILER_FLAG("-std=c++11" COMPILER_SUPPORTS_CXX11)
CHECK_CXX_COMPILER_FLAG("-std=c++0x" COMPILER_SUPPORTS_CXX0X)
if(COMPILER_SUPPORTS_CXX11)
  set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11")
elseif(COMPILER_SUPPORTS_CXX0X)
  set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++0x")
else()
  message(SEND_ERROR "The compiler ${CMAKE_CXX_COMPILER} has no C++11 support. Please use a different C++ compiler.")
endif()

IF(OS STREQUAL "arm-linux")
# set current cross-compiler style
    SET(CMAKE_SYSTEM_NAME Linux)
    # set c-compiler
    # SET(CMAKE_C_COMPILER "/opt/hisi-linux/x86-arm/arm-hisiv400-linux/target/bin/arm-hisiv400-linux-gcc")
    # set c++-compiler
    SET(CMAKE_CXX_COMPILER "/opt/hisi-linux/x86-arm/arm-hisiv400-linux/target/bin/arm-hisiv400-linux-g++")
ENDIF()

# MESSAGE(STATUS "CMAKE_INSTALL_PREFIX:" ${CMAKE_INSTALL_PREFIX})
# MESSAGE(STATUS "TARGETS:" ${TARGETS})
# MESSAGE(STATUS "PROJECT_NAME:" ${PROJECT_NAME})
# MESSAGE(STATUS "DESTINATION:" ${DESTINATION})

add_subdirectory(contrib/rutil)
add_subdirectory(src)

